/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Transaction.java
 *
 * Created on Feb 10, 2012, 12:03:03 PM
 */

package bank_syastem;

import java.sql.ResultSet;
import java.util.Vector;

/**
 *
 * @author Windows 7
 */
public class Transaction extends javax.swing.JFrame {
    String text1,text2;

    /** Creates new form Transaction */
    public Transaction() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        lbl_log_as = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        rdb_cheque = new javax.swing.JRadioButton();
        rdb_cash = new javax.swing.JRadioButton();
        rdb_atm = new javax.swing.JRadioButton();
        rdb_taller = new javax.swing.JRadioButton();
        txt_tid = new javax.swing.JTextField();
        txt_amount = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        date_chooser = new com.toedter.calendar.JDateChooser();
        jButton3 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        item_lst1 = new javax.swing.JScrollPane();
        lis2 = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        lis1 = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setForeground(new java.awt.Color(0, 51, 255));
        jLabel1.setText("Transaction");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 13, 79, 26));

        jLabel2.setText("Log As ");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(278, 19, -1, -1));
        jPanel1.add(lbl_log_as, new org.netbeans.lib.awtextra.AbsoluteConstraints(323, 27, 58, 12));

        jLabel3.setText("TID");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 78, 27, -1));

        jLabel4.setText("Date ");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 106, -1, -1));

        jLabel6.setText("Amount ");
        jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(12, 137, -1, -1));

        jLabel7.setText("Tranfaction From ");
        jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

        jLabel8.setText("Transaction To ");
        jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 190, -1, -1));

        jLabel9.setText("Transaction Method ");
        jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 390, -1, -1));

        jLabel10.setText("Transaction Mode ");
        jPanel1.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 320, -1, -1));

        buttonGroup2.add(rdb_cheque);
        rdb_cheque.setText("Cheque ");
        jPanel1.add(rdb_cheque, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 340, -1, -1));

        buttonGroup2.add(rdb_cash);
        rdb_cash.setText("Cash ");
        jPanel1.add(rdb_cash, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 370, -1, -1));

        buttonGroup2.add(rdb_atm);
        rdb_atm.setText("ATM");
        jPanel1.add(rdb_atm, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 410, -1, -1));

        buttonGroup2.add(rdb_taller);
        rdb_taller.setText("Teller ");
        jPanel1.add(rdb_taller, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 430, -1, -1));
        jPanel1.add(txt_tid, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 69, 170, -1));
        jPanel1.add(txt_amount, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 131, 170, -1));

        jButton1.setText("Ok");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 480, 69, -1));

        jButton2.setText("Clear");
        jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 480, 69, -1));
        jPanel1.add(date_chooser, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 100, 170, -1));

        jButton3.setText("Back");
        jPanel1.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 480, 77, -1));
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 13, 50, 26));

        item_lst1.setViewportView(lis2);

        jPanel1.add(item_lst1, new org.netbeans.lib.awtextra.AbsoluteConstraints(115, 186, 75, 106));

        jScrollPane2.setViewportView(lis1);

        jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 190, 80, 100));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-415)/2, (screenSize.height-561)/2, 415, 561);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String date="null";
        if(rdb_atm.isSelected())
        text1="atm";
        else
        text1="traller";
        
        if(rdb_cash.isSelected())
        text2="cash";
        else
           text2="cheque";
        
        try {
            ResultSet rs=DB.DB.search("select * from account_details");
            Vector v=new Vector();
            while(rs.next())
            {
            lis1.(v.add(rs.getString("acc_no")));
            }
        } catch (Exception e) {
        }
        DB.DB.change("insert into transaction values("+txt_tid.getText()+"','"+date+"','"+txt_amount.getText()+"','"+lis1.getSelectedValue()+"','"+lis2.getSelectedValue()+"','"+text1+"','"+text2+"')");
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Transaction().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private com.toedter.calendar.JDateChooser date_chooser;
    private javax.swing.JScrollPane item_lst1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lbl_log_as;
    private javax.swing.JList lis1;
    private javax.swing.JList lis2;
    private javax.swing.JRadioButton rdb_atm;
    private javax.swing.JRadioButton rdb_cash;
    private javax.swing.JRadioButton rdb_cheque;
    private javax.swing.JRadioButton rdb_taller;
    private javax.swing.JTextField txt_amount;
    private javax.swing.JTextField txt_tid;
    // End of variables declaration//GEN-END:variables

}
